/*
 * @Author: szx
 * @Date: 2022-06-13 14:14:32
 * @LastEditTime: 2022-06-13 14:25:31
 * @Description:
 * @FilePath: \leetcode\面试题\17\01\01.js
 */
/**
 * @param {number} a
 * @param {number} b
 * @return {number}
 */
var add = function (a, b) {
    let c = 0;
    while (b) {
        c = (a & b) << 1;
        a ^= b;
        b = c;
    }
    return a;
};

var add = function (a, b) {
    if (a == 0) return b;
    if (b == 0) return a;
    while (true) {
        let lower = a ^ b;
        let higher = (a & b) << 1;
        if (higher == 0) break;
        a = lower;
        b = higher;
    }
    return lower;
};
